#include"SList.h"

void SListTest1()
{
    SLTNode* n1 = (SLTNode*)malloc(sizeof(SLTNode));
    SLTNode* n2 = (SLTNode*)malloc(sizeof(SLTNode));
    SLTNode* n3 = (SLTNode*)malloc(sizeof(SLTNode));
    SLTNode* n4 = (SLTNode*)malloc(sizeof(SLTNode));
    n1->data = 1;
    n2->data = 2;
    n3->data = 3;
    n4->data = 4;

    n1->next = n2;
    n2->next = n3;
    n3->next = n4;
    n4->next = NULL;

    SListPrint(n1);

    SLTNode* plist = n1;
    SListPushBack(&plist, 5);
    SListPushBack(&plist, 6);
    SListPushBack(&plist, 7);
    SListPushBack(&plist, 8);
    SListPrint(n1);
}

void SListTest2()
{
    SLTNode* plist = NULL;
    SListPushBack(&plist,1);
    SListPushBack(&plist,2);
    SListPushBack(&plist,3);
    SListPushBack(&plist,4);
    SListPushBack(&plist,5);
    SListPrint(plist);
    SListPushFront(&plist, 0);
    SListPrint(plist);
}
void SListTest3()
{

    SLTNode* plist = NULL;
    SListPushFront(&plist, 0);
    SListPushFront(&plist, 1);
    SListPushFront(&plist, 2);
    SListPushFront(&plist, 3);
    SListPushFront(&plist, 4);
    SListPrint(plist);
    SListPopFront(&plist);
    SListPopFront(&plist);
    SListPopFront(&plist);
    SListPopFront(&plist);
   // SListPopBack(&plist);
    SListPrint(plist);
}
void SListTest4()
{

    SLTNode* plist = NULL;
    SListPushFront(&plist, 0);
    SListPushFront(&plist, 1);
    SListPushFront(&plist, 2);
    SListPushFront(&plist, 3);
    SListPushFront(&plist, 4);
    SListPrint(plist);

 //   SListPopFront(&plist);
 //   SListPrint(plist);

 //   SListPopFront(&plist);
 //   SListPrint(plist);

 //   SListPopFront(&plist);
 //   SListPrint(plist);

 //   SListPopFront(&plist);
 //   SListPrint(plist);
 //   SListPopFront(&plist);
 //   SListPrint(plist);
  //  SLTNode* ret = SListFind(plist, 2);
   // if(ret)
   // {
   //     ret->data = 888;
   // }
    SLTNode* pos = SListFind(plist, 2);
    if(pos)
    { 
   //      SListInsert(&plist, pos, 66);
         SListErase(&plist, pos);
         SListPrint(plist);
    }
   // SListInsert(&plist, NULL, 5);
}
int main()
{
    SListTest4();
    return 0;
}
